<?php
!defined('ADMIN') && exit('Not allowed to directly view page');

if(!isset($sucorder)){ $sucorder = 0; }
if(!isset($check)){  $check = 0; }

if(empty($action))
{
	require_once(DEDEINC.'/datalistcp.class.php');
	$wheresql = $check == 0 ? " where  sucorder=0 " :($check == 1 ? " where  sucorder=1 " :($check == 2?" where  sucorder=2  ":"  ") );
	$query = "select * from `#@__yy_order` $wheresql order by id desc";
	$dlist = new DataListCP();
	$dlist->pageSize = 15;
	$dlist->SetParameter("do",'yuyue_admin');
	$dlist->SetParameter("check",$check);
	$dlist->SetTemplet(DEDEADMIN."/templets/yuyue_admin.htm");
	$dlist->SetSource($query);
	$dlist->Display();
}
else if($action == 'delete')
{
	CheckPurview('a_Del');
	require_once(DEDEINC."/oxwindow.class.php");
	if(empty($fmdo))
	{
		$fmdo = "";
	}
	if($fmdo=="yes")
	{
		if($qstr=='')
		{
			ShowMsg("参数无效！",'-1');
			exit();
		}
		$qstrs = explode("`",$qstr);
		$okaids = Array();
		foreach($qstrs as $aid)
		{
			if(!isset($okaids[$aid]))
			{
				$dsql->ExecuteNoneQuery("delete from `#@__yy_order` where id='$aid' ");
			}else{
				$okaids[$aid] = 1;
			}
		}
		ShowMsg("成功删除指定的预约！",'?do=yuyue_admin');
		exit();
	}//确定刪除操作完成

	//删除确认消息
	$wintitle = "在线预约管理-删除预约";
	$wecome_info = "<a href='".$ENV_GOBACK_URL."'>在线预约管理</a>::删除预约";
	$win = new OxWindow();
	$win->Init("?do=yuyue_admin","js/blank.js","POST");
	$win->AddHidden("fmdo","yes");
	$win->AddHidden("action",$action);
	$win->AddHidden("qstr",$qstr);
	$win->AddHidden("aid",$aid);
	$win->AddTitle("你确实要删除“ $qstr  ”这些预约？");
	$winform = $win->GetWindow("ok");
	$win->Display();
	exit();
}
else if($action == 'success')
{
	CheckPurview('a_Commend');

	if($qstr=='')
	{
		ShowMsg("参数无效！",'-1');
		exit();
	}
	$qstrs = explode("`",$qstr);
	foreach($qstrs as $aid)
	{
		$aid = ereg_replace("[^0-9]","",$aid);
		if($aid==""){ continue; }
		$dsql->ExecuteNoneQuery("Update `#@__yy_order` set `sucorder`=1 where `id`='$aid'");
		//$dsql->SetQuery("Update `#@__yy_order` set `sucorder`=1 where `id`='$aid' ");
		//$dsql->ExecuteNoneQuery();
	}
	ShowMsg("预约成功！",'?do=yuyue_admin');
	exit();
}
else if($action == 'deal')
{
	CheckPurview('a_Commend');
	if($qstr=="")
	{
		ShowMsg("参数无效！",'-1');
		exit();
	}
	$qstrs = explode("`",$qstr);
	foreach($qstrs as $aid)
	{
		$aid = ereg_replace("[^0-9]","",$aid);
		if($aid==""){ continue; }
		$dsql->ExecuteNoneQuery("Update `#@__yy_order` set sucorder=2 where id='$aid' ");
		//$dsql->SetQuery("Update `#@__yy_order` set sucorder=2 where id='$aid' ");
		//$dsql->ExecuteNoneQuery();
	}
	ShowMsg("该预约 已经处理！",'?do=yuyue_admin');
	exit();
}

?>